package com.ncs.stm;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


public class Summary extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.summary);

        ListView listView = (ListView)findViewById(R.id.summary);

        String userid = getIntent().getStringExtra("userid");
        Map map = SelectedTips.userSurveyResultMap.get(userid);
        List<String> list = new ArrayList<String>();
        for(Object obj :map.keySet()){
            String key = (String)obj;
            List tempList = (List)map.get(key);
            List categoriesMap = SurveyTips.categories;
            for(Object catMap:categoriesMap){
                Map oMap = (Map)catMap;
                if(oMap.get("catId").equals(key) ){
                   list.add((String)oMap.get("surveyCatDesc"));
                }
            }

            for( Object o : tempList){
                Map tempMap = (Map)o;
                list.add((String)tempMap.get("tip_desc"));
            }
        }
        ArrayAdapter arrayAdapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1,list);

        listView.setAdapter(arrayAdapter);
    }
}